home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / TransSkel 3.24 / Demos / Pascal Demos / Button / Main.p < prev    next >
Text File  |  1996-01-24  |  2KB  |  110 lines

  1. { TransSkel button application in Pascal }
  2.  
  3. { 10 Feb 94 Version 1.00, Paul DuBois }
  4.  
  5. program Button;
  6.  
  7.     uses
  8.         Windows, Menus, ToolUtils, ButtonGlobals,
  9.         Modal1, Modal2, Modal3, Document, Modeless, Movable, TransSkel;
  10.  
  11.     const
  12.  
  13.         doModal1Item = 1;
  14.         doModal2Item = 2;
  15.         doModal3Item = 3;
  16.         doMovableItem = 4;
  17.     { sepLine }
  18.         quitAppItem = 6;
  19.  
  20.  
  21. {--------------------------------------------------------------------}
  22. { Menu handling procedures }
  23. {--------------------------------------------------------------------}
  24.  
  25.  
  26. { Handle selection of "About Button..." item from Apple menu }
  27.  
  28.     procedure DoAppleMenu (item: Integer);
  29.         var
  30.             ignore: Integer;
  31.     begin
  32.         ignore := SkelAlert(aboutAlrtRes, SkelDlogFilter(nil, true), skelPositionOnParentDevice);
  33.         SkelRmveDlogFilter;
  34.     end;
  35.  
  36.  
  37. { Process selection from File menu }
  38.  
  39.     procedure DoFileMenu (item: Integer);
  40.     begin
  41.         case item of
  42.             doModal1Item: 
  43.                 DoModal1;
  44.             doModal2Item: 
  45.                 DoModal2;
  46.             doModal3Item: 
  47.                 DoModal3;
  48.             doMovableItem: 
  49.                 DoMovableModal;
  50.             quitAppItem: 
  51.                 SkelStopEventLoop;
  52.         end;
  53.     end;
  54.  
  55.  
  56.     procedure AdjustMenus;
  57.         var
  58.             m: MenuHandle;
  59.     begin
  60.         m := GetMenuHandle(skelAppleMenuID);
  61.         if (SkelIsMMDlog(FrontWindow)) then
  62.             DisableItem(m, 1)
  63.         else
  64.             EnableItem(m, 1);
  65.         m := GetMenuHandle(fileMenuRes);
  66.         if (SkelIsMMDlog(FrontWindow)) then
  67.             begin
  68.                 DisableItem(m, doModal1Item);
  69.                 DisableItem(m, doModal2Item);
  70.                 DisableItem(m, doModal3Item);
  71.                 DisableItem(m, doMovableItem);
  72.             end
  73.         else
  74.             begin
  75.                 EnableItem(m, doModal1Item);
  76.                 EnableItem(m, doModal2Item);
  77.                 EnableItem(m, doModal3Item);
  78.                 EnableItem(m, doMovableItem);
  79.             end;
  80.     end;
  81.  
  82.  
  83. { Initialize menus.  Tell TransSkel to process the Apple menu }
  84. { automatically, and associate the proper procedures with the }
  85. { File menu. }
  86.  
  87.     procedure SetupMenus;
  88.         var
  89.             m: MenuHandle;
  90.             ignore: Boolean;
  91.     begin
  92.         SkelApple('About Button…', @DoAppleMenu);
  93.         m := GetMenu(fileMenuRes);
  94.         ignore := SkelMenu(m, @DoFileMenu, nil, false, true);
  95.         if (SkelQuery(skelQSysVersion) < $00000700) then
  96.             DisableItem(m, doMovableItem);
  97.     end;
  98.  
  99.  
  100. begin
  101.     SkelInit(nil);
  102.     horizRatio := FixRatio(1, 2);
  103.     vertRatio := FixRatio(1, 5);
  104.     SetupMenus;
  105.     SetupDocument;
  106.     SetupModeless;
  107.     InitMovableModal;
  108.     SkelEventLoop;
  109.     SkelCleanup;
  110. end.